package com.changwu.cwbase.temples.activity;

import android.os.Bundle;

import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.ToastUtils;
import com.changwu.cwbase.R;
import com.changwu.cwbase.Constants;
import com.changwu.cwbase.base.ActivityBase;
import com.changwu.cwbase.bean.response.ResultResponse;
import com.changwu.cwbase.net.ApiM;
import com.changwu.cwbase.net.RxObserver;
import com.changwu.cwbase.net.RxSchedulers;

/*
 * 网络请求使用模板
 */
public class TempNetActivity extends ActivityBase {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_temp);
        initView();
    }

    @Override
    public void initToolBar() {
        super.initToolBar();
        title.setText("模板");
    }

    private void initView() {
    }

    //获取信息需要验证登录状态
    private void reqUpdate() {
        JSONObject params = new JSONObject();
        params.put("uid", "");
        ApiM.getInstance().getUserService().getcode(params).compose(RxSchedulers.<ResultResponse>io_main()).subscribeWith(new RxObserver<ResultResponse>(TAG, 0) {
            @Override
            public void success(ResultResponse response) {
                if (response.errno == Constants.success) {

                } else if (response.errno == Constants.UNLOGIN) {

                } else {
                    ToastUtils.showShort(response.errmsg);
                }
            }
        });
    }

    //上传数据不需要验证登录状态
    private void versionUpdate() {
        JSONObject params = new JSONObject();
        params.put("uid", "");
        ApiM.getInstance().getUserService().getcode(params).compose(RxSchedulers.<ResultResponse>io_main()).subscribeWith(new RxObserver<ResultResponse>(TAG, 0) {
            @Override
            public void success(ResultResponse response) {
                if (response.errno == Constants.success) {

                } else {
                    ToastUtils.showShort(response.errmsg);
                }
            }
        });
    }
}
